{% extends "base.html" %}
<link rel="stylesheet" href="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/css/scoreboard.css">
{% block content %}
<div class="jumbotron">
	<div class="container">
		<h1>Scoreboard</h1>
	</div>
</div>
<div class="container">
	{% if errors %}
	<div id='errors' class="row">
		<div class="col-md-12">
		{% for error in errors %}
			<h1 class="text-center">{{ error }}</h1>
		{% endfor %}
		</div>
	</div>
	{% else %}

	{% if score_frozen %}
	<div class="row">
		<div class="col-md-12">
			<h1 class="text-center">排行榜已经冻结</h1>
		</div>
	</div>
	{% endif %}

	<div id="score-graph" class="row">
		<div class="col-md-12 text-center">
			<i class="fas fa-circle-notch fa-spin fa-3x fa-fw spinner"></i>
		</div>
	</div>

	{% if teams %}
	<div id="scoreboard" class="row">
		<div class="col-md-12">
			<table class="table table-striped">
				<thead>
					<tr>
						<td scope="col" width="100px"><b>排名</b></td>
						<td scope="col"><b>用户</b></td>
						<td scope="col"><b>分数</b></td>
                        <td scope="col"><b>通过数</b></td>
					</tr>

				</thead>
				<tbody>
                {% for team in teams %}
                    {% if team[1]== username %}
                        <tr>
						<td scope="col"><b>{{ loop.index }}</b></td>
						<td scope="col">
                            <span class="badge badge-info">我</span>
                            <span><b>{{ username }}</b></span>
                        </td>
						<td scope="col"><b>{{ team[2] }}</b></td>
                        <td scope="col"><b>{{ team[3] }}</b></td>
					</tr>
                    {% endif %}
                {% endfor %}
				{% for team in teams %}
					<tr>
                    <!--scope="row" class="text-center"-->
						<td>{{ loop.index }}</td>
						<td><a href="{{ request.script_root }}/team/{{ team.teamid }}">{{ team.name | truncate(100) }}</a></td>
						<td>{{ team.score }}</td>
                        <td>{{ team.solves_count }}</td>
					</tr>
				{% endfor %}
				</tbody>
			</table>
		</div>
	</div>
	{% endif %}
	{% endif %}
</div>
{% endblock %}

{% block scripts %}
	<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/vendor/plotly.min.js"></script>
	<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/utils.js"></script>
	<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/scoreboard.js"></script>
{% endblock %}
